home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / INITOVLY.MOD < prev    next >
Text File  |  1987-06-09  |  4KB  |  110 lines

  1. (*----------------------------------------------------------------------*)
  2. (*              InitOvly --- Initialize PibTerm overlays                *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE InitOvly;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     PROCEDURE:  InitOvly                                             *)
  10. (*                                                                      *)
  11. (*     Purpose:    Initializes PibTerm directory for overlay searches   *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        InitOvly;                                                     *)
  16. (*                                                                      *)
  17. (*     Remarks:                                                         *)
  18. (*                                                                      *)
  19. (*        The PibTerm directory should have been set by a previous      *)
  20. (*        SET PIBTERM=   DOS specification.                             *)
  21. (*                                                                      *)
  22. (*----------------------------------------------------------------------*)
  23.  
  24. VAR
  25.    Ovr_Dir      : AnyStr;
  26.    Ierr         : INTEGER;
  27.    I            : INTEGER;
  28.  
  29. (* STRUCTURED *) CONST
  30.    LetSet : SET OF CHAR = ['A'..'Z','a'..'z','\'];
  31.  
  32. BEGIN (* InitOvly *)
  33.                                    (* Search DOS environment for     *)
  34.                                    (* PIBTERM= definition.           *)
  35.  
  36.    Ovr_Dir := GetEnvStr('PIBTERM');
  37.  
  38.                                    (* See if environment string      *)
  39.                                    (* makes sense.                   *)
  40.  
  41.    IF ( LENGTH( Ovr_Dir ) > 0 ) THEN
  42.       IF ( NOT ( Ovr_Dir[1] IN LetSet ) ) THEN
  43.          Ovr_Dir[0] := #0;
  44.  
  45.    IF ( LENGTH( Ovr_Dir ) > 0 ) THEN
  46.       BEGIN
  47.                                    (* PIBTERM= found in environment --- *)
  48.                                    (* set home drive and directory      *)
  49.  
  50.          IF ( Ovr_Dir[2] = ':' ) THEN
  51.             BEGIN
  52.                Home_Drive    := UpCase( Ovr_Dir[1] );
  53.                IF LENGTH( Ovr_Dir ) > 2 THEN
  54.                   Home_Dir_Path := COPY( Ovr_Dir, 3, LENGTH( Ovr_Dir ) - 2 )
  55.                ELSE
  56.                   Home_Dir_Path[0] := #0;
  57.             END
  58.          ELSE
  59.             BEGIN
  60.                Home_Drive    := Dir_Get_Default_Drive;
  61.                Home_Dir_Path := Ovr_Dir;
  62.             END;
  63.  
  64.          IF ( LENGTH( Home_Dir_Path ) > 0 ) THEN
  65.             IF ( Home_Dir_Path[ LENGTH( Home_Dir_Path ) ] = '\' ) THEN
  66.                IF LENGTH( Home_Dir_Path ) > 1 THEN
  67.                   Home_Dir_Path := COPY( Home_Dir_Path, 1,
  68.                                          LENGTH( Home_Dir_Path ) - 1 )
  69.                ELSE
  70.                   Home_Dir_Path[0] := #0;
  71.  
  72.          IF ( LENGTH( Home_Dir_Path ) > 0 ) THEN
  73.             IF ( Home_Dir_Path[ 1 ] = '\' ) THEN
  74.                IF LENGTH( Home_Dir_Path ) > 1 THEN
  75.                   Home_Dir_Path := COPY( Home_Dir_Path, 2,
  76.                                          LENGTH( Home_Dir_Path ) - 1 )
  77.                ELSE
  78.                   Home_Dir_Path[0] := #0;
  79.  
  80.       END
  81.    ELSE
  82.       BEGIN
  83.                                    (* No PIBTERM= in environment ---  *)
  84.                                    (* get current drive and directory *)
  85.  
  86.          Home_Drive := Dir_Get_Default_Drive;
  87.  
  88.          Ierr := Dir_Get_Current_Path( Home_Drive, Home_Dir_Path );
  89.  
  90.       END;
  91.                                    (* Make PibTerm files findable    *)
  92.  
  93.    IF ( LENGTH( Home_Dir_Path ) <> 0 )  THEN
  94.       Home_Dir := Home_Drive + ':\' + Home_Dir_Path + '\'
  95.    ELSE
  96.       Home_Dir := Home_Drive + ':\';
  97.  
  98.                                    (* Set Home_Dir as first path to *)
  99.                                    (* check in BigTurbo sequence.   *)
  100.  
  101.    FOR I := NumPathNames DOWNTO 1 DO
  102.       IF ( SUCC( I ) < MaxPathEntries ) THEN
  103.          DOSPathNames[SUCC(I)] := DOSPathNames[I];
  104.  
  105.    DOSPathNames[1] := Home_Dir;
  106.    BestPathNum     := 1;
  107.    NumPathNames    := MIN( SUCC( NumPathNames ) , MaxPathEntries );
  108.  
  109. END    (* InitOvly *);
  110.